package com.offcn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Delete {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //创建链接对象
        Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/myschool", "root", "root");
        //创建sql平台
        Statement stmt= conn.createStatement();
        //执行SQL语句并返回结果
        String sql="delete from accou where id=5";
        int num = stmt.executeUpdate(sql);
        if(num>0){
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
        conn.close();
        stmt.close();
    }
}
